
import {IonicPage, NavController, NavParams} from "ionic-angular";
import {Component, ElementRef, ViewChild} from "@angular/core";
import {HttpService} from "../../../../providers/HttpService";
import {NativeServiceC} from "../../../../providers/NativeServiceC";

@IonicPage()
@Component({
  selector: 'page-themeBook',
  templateUrl: 'topDetail.html'
})

export class topDetailPage{

  topDetailList={};
  private dataId= this.navParams.get('data') || 202;
  private topDetailUrl= '/ranking/';

  constructor(public navCtrl: NavController,
              public httpServe:HttpService,
              public nativeService:NativeServiceC,
              public privateElementRef:ElementRef,
              public navParams:NavParams){

  }

  @ViewChild('week')
  greetWeek: ElementRef;
  ngAfterViewInitWeekRed() {
    this.greetWeek.nativeElement.style.color ='red';
  }
  ngAfterViewInitWeekBlack() {
    this.greetWeek.nativeElement.style.color ='#333333';
  }
  @ViewChild('new')
  greetNew: ElementRef;
  ngAfterViewInitNewRed() {
    this.greetNew.nativeElement.style.color ='red';
  }
  ngAfterViewInitNewBlack() {
    this.greetNew.nativeElement.style.color ='#333333';
  }

  @ViewChild('more')
  greetMore: ElementRef;
  ngAfterViewInitMoreRed() {
    this.greetMore.nativeElement.style.color ='red';
  }
  ngAfterViewInitMoreBlack() {
    this.greetMore.nativeElement.style.color ='#333333';
  }

  ionViewDidLoad(){
    this.ngAfterViewInitWeekRed();
    console.log(this.dataId);
    let classify = this.dataId._id;
    this.searchtopDetailList(classify);
  }


//周榜
  searchWeekSale(){
    this.ngAfterViewInitWeekRed();
    this.ngAfterViewInitNewBlack();
    this.ngAfterViewInitMoreBlack();
    let classify = this.dataId._id;
    this.searchtopDetailList(classify);
  }

//月榜
  searchMonthSale(){
    this.ngAfterViewInitNewRed();
    this.ngAfterViewInitWeekBlack();
    this.ngAfterViewInitMoreBlack();
    let NewIssue = this.dataId.monthRank;
    this.searchtopDetailList(NewIssue);
  }

//总榜
  searchTotalSale(){
    this.ngAfterViewInitMoreRed();
    this.ngAfterViewInitNewBlack();
    this.ngAfterViewInitWeekBlack();
    let MoreCollect = this.dataId.totalRank;
    this.searchtopDetailList(MoreCollect);
  }


  private searchtopDetailList (temp){
    this.httpServe.get(this.topDetailUrl+temp).subscribe(res=>{
      this.topDetailList = res.ranking;
      this.nativeService.hideLoading();
    })
  }


}


